#ifndef modbus_rtu_slave_H
#define	modbus_rtu_slave_H

#include "modbus_rtu_bsp.h"

#define mbrtusize_r 32
#define mbrtusize_t 32

typedef enum
{
	MBS_STATE_IDLE=0X00,
	MBS_STATE_GETDATA,
	MBS_STATE_ERROR,
	
}mb_slave_state;

typedef struct mb_rtu 
{  
	uint8_t RX_Buffer[mbrtusize_r];
	uint8_t TX_Buffer[mbrtusize_t];
	uint8_t RTU_PDU[32];
	uint16_t mbdatacnt;
	uint16_t address;
	uint8_t MB_SLAVE_STATE;
}MB_RTU; 

extern MB_RTU MBRTU_slave;

extern uint16_t RTUholdreg[32];
extern uint16_t RTUinputreg[32];

void mbrtu_init(void);
void mbrtu_pcs(void);

uint16_t __CRC16(uint8_t *puchMsg, uint16_t usDataLen);




#endif /* modbus_rtu_slave_H */
